/*
 * $Id: QEADIFShared.h 72 2009-06-18 17:07:56Z jon@bway.net $
 * Chalk
 *
 * Created 5/31/09
 * Copyright Jon Gordon
 * 
 * Permission is hereby granted, free of charge, to any person obtaining 
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including 
 * without limitation the rights to use, copy, modify, merge, publish, 
 * distribute, sublicense, and/or sell copies of the Software, and to 
 * permit persons to whom the Software is furnished to do so, subject to 
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#import <Foundation/Foundation.h>

#import "QEADIFError.h"

/*
 * The two sets of constants here represent different contexts in which
 * ADIF types come up.  We need to be able to distinguish types
 * internally, so the first list has distinct values for each of the
 * ADIF types.
 *
 * The ADIF standard, however, also sets up single-letter codes for
 * each of the types.  The problem is that a code can signify more
 * than one type: 's', for example, can indicate a character, or a
 * string, or a multiline string.  And there's no code for enumeration
 * types, which kind of makes sense--or about as much sense as anything
 * else about ADIF does--but it means that this set of codes is 
 * inadequate to be used in all contexts to distinguish type.  So the 
 * second set of constants is defined, but merely to replace
 * magic numbers (or characters) with meaningful constants.
 */
typedef enum {
    qeADIFTypeUndefined = 1025,
    qeADIFTypeAwardList = 1,
    qeADIFTypeBoolean,
    qeADIFTypeDigit,
    qeADIFTypeNumber,
    qeADIFTypeCharacter,
    qeADIFTypeDate,
    qeADIFTypeTime,
    qeADIFTypeString,
    qeADIFTypeMultilineString,
    qeADIFTypeLocation,
    qeADIFTypeEnumeration
} QEADIFType;

typedef enum {
    qeADIFDataTypeUnspecified =  0,
    qeADIFDataTypeAwardList = 'a',
    qeADIFDataTypeBoolean =   'b',
    qeADIFDataTypeDate =      'd',
    qeADIFDataTypeLocation =  'l',
    qeADIFDataTypeDigit =     'n',
    qeADIFDataTypeNumber =    'n',
    qeADIFDataTypeCharacter = 's',
    qeADIFDataTypeString =    's',
    qeADIFDataTypeMultilineString = 's',
    qeADIFDataTypeTime =      't',
    qeADIFDataTypeEnumeration = 0xfffe
} QEADIFDataTypeCode;


/*
 * Names for the various ADIF types.
 */
#define qeADIFTypeNameUndefined       @"(undefined)"
#define qeADIFTypeNameAwardList       @"AwardList"
#define qeADIFTypeNameBoolean         @"Boolean"
#define qeADIFTypeNameDigit           @"Digit"
#define qeADIFTypeNameNumber          @"Number"
#define qeADIFTypeNameCharacter       @"Character"
#define qeADIFTypeNameDate            @"Date"
#define qeADIFTypeNameTime            @"Time"
#define qeADIFTypeNameString          @"String"
#define qeADIFTypeNameMultilineString @"MultilineString"
#define qeADIFTypeNameLocation        @"Location"
#define qeADIFTypeNameEnumeration     @"Enumeration"


/*
 * The ADIF specification defines several named Enumerations.  The
 * following keys identify each Enumeration.
 */
#define qeADIFEnumAntPath      @"Ant Path"
#define qeADIFEnumARRLSection  @"ARRL Section"
#define qeADIFEnumAward        @"Award"
#define qeADIFEnumBand         @"Band"
#define qeADIFEnumContestID    @"Contest ID"
#define qeADIFEnumMode         @"Mode"
#define qeADIFEnumPropMode     @"Propagation Mode"
#define qeADIFEnumPrimAdminSub @"Primary Administrative Subdivisions"
#define qeADIFEnumSecAdminSub  @"Secondary Administrative Subdivisions"
#define qeADIFEnumDXCC         @"DXCC"

/*
 * Each entry in an Enumeration has at least one field, for the entry's
 * value.  The following keys designate the fields used.
 */
#define qeADIFEnumFieldValue     @"value"
#define qeADIFEnumFieldMeaning   @"meaning"
#define qeADIFEnumFieldLowerFreq @"lower freq"
#define qeADIFEnumFieldUpperFreq @"upper freq"
#define qeADIFEnumFieldDeleted   @"deleted"


#define ADIF_BOOLEAN_TRUE @"Y"
#define ADIF_BOOLEAN_FALSE @"N"
